package com.taplinker.client.im.rpc.response;

import java.util.Date;

import com.taplinker.client.im.domain.ImDataCenter;
import com.taplinker.client.im.protocol.TapLinkerMessage;
import com.taplinker.client.im.rpc.body.Cmd1012Rep;
import com.taplinker.core.rpc.Result;
import com.taplinker.core.util.json.JsonUtil;

public class Cmd1012 implements ImResponse{

	@Override
	public void yes(Result result) {
		Cmd1012Rep rep = JsonUtil.jsonToObject(result.object.toString(), Cmd1012Rep.class);
		
		TapLinkerMessage message = new TapLinkerMessage();
		message.setContent(rep.getContent());
		message.setConversationId(rep.getConversationId());
		message.setId(rep.getId());
		message.setType(rep.getType());
		message.setSendTime(new Date(rep.getSendTime()));
		message.setSendUser(rep.getSendUser());
		message.setSendVistor(rep.getSendVisitor());
		message.setSendUserId(rep.getSendUserId());
		message.setRead(rep.getRead());
		
		ImDataCenter.getInstance().addToPubMessage(message);
		
	}

	@Override
	public String getCommand() {
		return "1012";
	}

}